<template>
  <div>
    <div>
      <div class="header">
       员工基本数据统计

      </div>
      <div>
        <div id="back4" ></div>
      </div>

    </div>
  </div>

</template>

<script>
import axios from "axios";
import  { mapState } from 'vuex'
export default {
  name: "PersonDetail",
  data(){
    return{
      Per:[
        { value: 4, name: '黑名单' },
        { value: 8, name: '白名单' },
        { value: 4, name: '离职员工' },
        { value: 8, name: '在职员工' },
        { value: 4, name: '全部员工' },


      ]
    }
  },
  computed:{
    ...mapState(['setPerson'])
  },

  methods:{
    getEchartData(){
      const myChart = this.$echarts.init(document.getElementById("back4"))//引入到盒子

      const option = {
        title: {
          text: '员工基本数据统计',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: ' 员工基本数据统计',
            type: 'pie',
            radius: '50%',
            data: this.setPerson,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);

    },
    setYuan(){
      axios({
        url: 'http://132.232.110.185/personnelManagement/dataStatistics/selectEmployeeGroupBy',
        method: 'get',

      }).then((response) => {

        this.$store.dispatch('setPerson',response.data.data)


      })
    }
  },


  mounted() {
    this.getEchartData()
    this.setYuan()
  }
}
</script>

<style scoped>
.header{
  width: 100%;
  height: 74px;
  border-bottom: 1px solid rgba(0,0,0,0.3);
  padding-left:12px ;
  line-height: 74px;
  font-size: 18px;
}
#back4{
  width: 100%;
  text-align: center;
  height: 700px;
  line-height: 700px;
  margin:22px auto 0;

}
</style>


